﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using Exam.Core.DBUtility;

namespace Exam.Core.SQLDAL
{
    public class TacticsKnowledges {

        /// <summary>
        /// 知识点列表
        /// </summary>
        /// <param name="typeid"></param>
        /// <param name="courseid"></param>
        /// <returns></returns>
        internal List<Exam.Core.Model.TacticsKnowledge> getListByTypeId(string typeid, string courseid) {

            List<Exam.Core.Model.TacticsKnowledge> list = new List<Exam.Core.Model.TacticsKnowledge>();

            string SQL1 = "SELECT DISTINCT QuestionKnowledgeId FROM Question WHERE QuestionTypeId=" + typeid + " AND CourseId=" + courseid;

            string SQL = "SELECT * FROM Knowledge WHERE KnowledgeId in (" + SQL1 + " ) ";
            DataTable dt = DbHelperSQL.Query(SQL).Tables[0];//DbHelperSQL

            foreach (DataRow dr in dt.Rows) {
                Exam.Core.Model.TacticsKnowledge obj = new Exam.Core.Model.TacticsKnowledge();

                obj.Id = dr["KnowledgeId"].ToString().Trim();
                obj.Title = dr["KnowledgeTitle"].ToString().Trim();
                obj.Parent = courseid;
                obj.QuestionList = null;//new Question().getQuestionByKnowledgeId(obj.Id);//知识点下试题
                obj.QuestionDifficulties = new QuestionDifficulties().getListByKnowledgeId(obj.Id, typeid, courseid);//难度列表以及难度下试题数目
                list.Add(obj);
            }

            return list;

        }
    }
}
